<template>
	<view>
		<view class="margin-sm ">
			<view class="bg-white radius padding-sm margin-bottom-sm">
				<view class="font-34rpx juzhong">
					{{data.orgName||'加载中'}}
				</view>
			</view>



			<view>
				<div v-for="(item,index) in data.images.split(',')">
					<image style="width: 730rpx;height: 760rpx" :src="item"></image>
				</div>
			</view>



		</view>
		<view class=" flex justify-between padding-sm" style="position: absolute;bottom: 10rpx;">
			<view style="flex: 1;" class="bg-pink radius padding-sm " @click="callPhone">
				<view class="juzhong font-34rpx">
					联系商家
				</view>
				<view class="juzhong font-13 " v-for="item in data.phone.split(',')">
					{{item}}
				</view>
			</view>
			<view style="flex: 2;" class="bg-pink  radius margin-left-sm padding-sm">
				<view class="juzhong font-34rpx">
					导航前往
				</view>
				<view class="juzhong font-13 ">
					{{data.address}}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		listByDistance10
	} from "@/api/shop/shopconfig/ShopConfigManagementApi.js"
	export default {
		data() {
			return {
				data: {
					title: '名称加载中',
					phone: '联系方式加载中',
					images: '/static/images/dianpu1.jpg',
					addres: '地址加载中',
					distance: '100',
					isidle: 0,
					tag: ['可吸烟', '好停车', '有厕所']
				}
			}
		},
		onLoad(e) {
			this.data.id = e.id
			this.getdata()
		},

		methods: {
			getdata() {
				this.listByDistance10()
			},
			callPhone() {
				let _this = this
				if (this.data.phone != null) {
					if (this.data.phone.split(',').length > 0) {
						uni.showActionSheet({
							title: "请选择拨打的号码",
							itemList: _this.data.phone.split(','),
							success: function(res) {

								_this.call(_this.data.phone.split(',')[res.tapIndex])
								// console.log('选中了第' + (res.tapIndex + 1) + '个按钮');
							},
							fail: function(res) {
								// console.log(res.errMsg);
							}
						});
					} else {
						this.call(this.data.phone)
					}

				} else {
					uni.showModal({
						title: "提示",
						content: "商家未正确配置联系方式,请从其他渠道联系商家",
						showCancel: false
					})
					return
				}
			},
			call(phone) {

				uni.makePhoneCall({
					phoneNumber: phone,
					success: function() {
						console.log('拨打电话成功');
					},
					fail: function(error) {
						console.log('拨打电话失败', error);
					}
				});

			},

			async listByDistance10(id) {
				let {
					data
				} = await listByDistance10({
					id: this.data.id
				})
				this.data = data[0]
			},
		}
	}
</script>

<style>

</style>